package excel

import (
	"fmt"
	"github.com/xuri/excelize/v2"
)

// GetRows 获取对应sheet的数据
func GetRows(fileName string, sheetName string) ([][]string, error) {
	file, err := excelize.OpenFile(fileName)
	if err != nil {
		return nil, err
	}
	defer func() {
		if errClose := file.Close(); errClose != nil {
			fmt.Println(errClose)
		}
	}()

	// 获取 Sheet1 上所有单元格
	rows, err := file.GetRows(sheetName)
	if err != nil {
		return nil, err
	}
	return rows, nil
}
